//
//  XYCallDetailCell.m
//  Zhihuijinfu
//
//  Created by XY Lv on 17/3/26.
//  Copyright © 2017年 王笛. All rights reserved.
//

#import "XYCallDetailCell.h"

@implementation XYCallDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self xyInitCellStyle];
        [self xyInitSubviews];
//        [self xySetSubviewsColor];
    }
    return self;
}

- (void)xyInitCellStyle{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)xyInitSubviews{
    _headImgView = [[UIImageView alloc]init];
    [self.contentView addSubview:_headImgView];
    self.headImgView.contentMode = UIViewContentModeScaleAspectFill;
    self.headImgView.layer.masksToBounds = YES;
    
    _userNameLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_userNameLabel];
    
    _publishTimeLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_publishTimeLabel];
    
    _contentLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_contentLabel];
    _contentLabel.numberOfLines = 0;
    _contentLabel.lineBreakMode = NSLineBreakByTruncatingTail;
    
    _lineView = [[UIView alloc]init];
    [self.contentView addSubview:_lineView];
}

- (void)xySetSubviewsStyle{
    _headImgView.layer.cornerRadius = CGRectGetWidth(self.headImgView.frame)/2;
    _headImgView.userInteractionEnabled = YES;

    _userNameLabel.textColor = xyUserNameTextColor;
    _userNameLabel.font = xyUserNameTextFont;

    _contentLabel.font = xyCallDetailCommentContentFont;
_contentLabel.textColor =  xyCallContentColor;
    
    _publishTimeLabel.textColor = xyPublisTimeTextColor;
    _publishTimeLabel.font = xyPublisTimeFont;
    _publishTimeLabel.textAlignment = NSTextAlignmentRight;
}

- (void)xySetSubviewsColor{
    _headImgView.backgroundColor = [UIColor greenColor];
    _userNameLabel.backgroundColor = [UIColor yellowColor];
    _publishTimeLabel.backgroundColor = [UIColor brownColor];
    _lineView.backgroundColor = [UIColor redColor];
}

- (void)setDetailFrame:(XYCallDetailFrame *)detailFrame{
    _detailFrame= detailFrame;
    [self xySetSubviewsStyle];
    [self xySetSubviewsFrame];
    [self xySetSubviewsData];
}

- (void)xySetSubviewsFrame{
    
    _headImgView.frame = _detailFrame.headImgViewF;
    _userNameLabel.frame = _detailFrame.userNameLabelF;
    _publishTimeLabel.frame = _detailFrame.publishTimeLabelF;
    _contentLabel.frame = _detailFrame.contentLabelF;
    _lineView.frame = _detailFrame.lineViewF;

}

- (void)xySetSubviewsData{
    [_headImgView sd_setImageWithURL:[NSURL URLWithString:_detailFrame.commentItem.image_url] placeholderImage:[UIImage imageNamed:@""]];
    _userNameLabel.text = _detailFrame.commentItem.create_name;
    _publishTimeLabel.text = _detailFrame.commentItem.create_time;
    _contentLabel.text = _detailFrame.commentItem.content;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end











